package org.lisz.order.controller;

import org.lisz.order.po.Order;
import org.lisz.order.properties.OrderProperties;
import org.lisz.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

//@RefreshScope   //自动刷新
@RestController
@RequestMapping("/order")
public class OrderCotroller {
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderProperties orderProperties;

//    @Value("${order.timeout}")
//    String orderTimeOut;


    @GetMapping("/create")
    private Order getOrder(@RequestParam("productId") Long productId, @RequestParam("userId") Long userId) {
        return orderService.crateOrder(productId, userId);
    }

    @GetMapping("/getConfig")
    public String getConfig() {
//        return orderProperties.getTimeout();
        return "mybatis-mapper-locations=" + orderProperties.getMapperLocations()
                + "mybatis-plus-map-underscore-to-camel-case=" + orderProperties.getCamelCase();

    }
}


